<?php $GLOBALS['script'][] = function() {?><script>
vue.data.choice_pack = {};
vue.data.form.pack_id = null;
vue.methods.dayToMinute = function (day) {
    return Math.round(day / 144) / 10;
};
vue.methods.getRowByRowsId = window.getRowByRowsId;
vue.methods.operate_repack = function () {
    var msg = "";
    msg += "该过程需要10~15分钟时间，数据保留但建议先备份\r\n";
    msg += "↓↓↓您要变更配置的主机信息↓↓↓\r\n";
    //msg += "主机远程登录地址：" + vue.data.choice_hostuser.rdpaddr + ":" + vue.data.choice_hostuser.rdpport + "\r\n";
    msg += "当前要操作的主机公网IP为：" + vue.data.choice_hostuser.vps_wanipv4 + "\r\n";
    msg += "确定要【变更配置】吗？";
    if (confirm(msg)) {
        vue.data.form.action = 'repack';
        vue.methods.submit_operate();
    }
};
if (!vue.hasOwnProperty('computed')) vue.computed = {};
vue.computed.rows_pack2 = function () {
    if (!vue.hasOwnProperty('data')) return [];
    if (!vue.data.hasOwnProperty('apidata')) return [];
    if (!vue.data.apidata.hasOwnProperty('rows_pack')) return [];
    const allow_packs = vue.data.choice_hostuser.host_packlist.split(',');
    const rows = [];
    const len = vue.data.apidata.rows_pack.length;
    for (var i = 0; i < len; i++) {
        const row = vue.data.apidata.rows_pack[i];
        if (allow_packs.indexOf(row.id) === -1) continue;
        rows.push(row);
    }
    if (rows.length > 0) {
        const pack = vue.methods.getRowByRowsId(rows, vue.data.form.pack_id);
        if (pack) {
            vue.data.choice_pack = pack;
        }
    }
    return rows;
};
</script><?php }?>
<form class="form-horizontal" action="" method="post" v-on:submit="operate_repack" onsubmit="return false;">
    <div class="box-body">
        <div class="form-group">
            <label for="select_pack_id" class="col-sm-3 control-label">
                选择套餐
            </label>
            <div class="col-sm-9">
                <select class="form-control" id="select_pack_id" v-model="form.pack_id" v-on:change="choice_pack=getRowByRowsId(apidata.rows_pack, form.pack_id)">
                    <option v-for="(row) in rows_pack2"
                    :value="row.id"
                    >
                    [{{row['name']}}]{{row['title']}}, 每天{{row['dayminpoint']}}点数, 每月{{(row['dayminpoint']*30/10000)}}万点
                    </option>
                </select>
                <div class="">
                    您选择的是[{{choice_pack['name']}}]{{choice_pack['title']}} 说明：{{choice_pack['note']}}<br />
                    CPU限制：<span style="color:red">{{choice_pack['limit_cpucore']}}</span>核，
                    保证运存：<span style="color:red">{{choice_pack['limit_ramgb']}}GB</span>
                    <span v-if="choice_hostuser['host_type']==1">（实际可能1-3倍）</span><br />
                    <span v-if="choice_hostuser['host_type']==1">
                        可用空间：<span style="color:red">{{choice_pack['limit_storagegb']}}GB</span>
                        （实际可能2-10倍），
                        端口映射：<span style="color:red">{{choice_pack['limit_portmap']}}</span>个
                    </span>
                    <span v-if="choice_hostuser['host_type']==2">
                        系统盘空间：<span style="color:red">{{choice_pack['limit_storagegb']}}GB</span>
                        （无独立数据盘）<br />
                    </span>
                    <span v-if="choice_hostuser['host_type']==2">
                        每日<font color="red">固定</font>收费
                    </span>
                    <span v-else>
                        每日<font color="red">保证最低</font>消费
                    </span>
                    <span style="color:red">{{choice_pack['dayminpoint']}}</span>点数,
                    每月<span style="color:red">{{(choice_pack['dayminpoint']*30/10000)}}万</span>点<br />
                    <span v-if="choice_hostuser['host_type']==2">
                        独立VPS<span style="color:red">按分钟计费</span>，
                        每分钟计费<span style="color:red">{{dayToMinute(choice_pack['dayminpoint'])}}</span>点数，
                        如您开机只玩60分钟立马销毁只收<span style="color:red">{{dayToMinute(choice_pack['dayminpoint'])*60}}</span>点数
                        <br />
                    </span>
                    <span v-if="choice_hostuser['host_type']==1" style="color:blue">
                        若当日消费低于{{choice_pack['dayminpoint']}}点数,次日将产生保底账单
                        <br />
                    </span>
                    <br />
                </div>
            </div>
        </div>
    </div>
    <div class="box-footer">
        <div class="box-footer col-sm-6 col-xs-12">
            <button type="submit" class="btn btn-warning btn-block btn-flat" :disabled="disabled>0">更换配置</button>
        </div>
        <div class="box-footer col-sm-6 col-xs-12">
            <button type="button" class="btn btn-default btn-block btn-flat" v-on:click="tabclick('info')">返回详情</button>
        </div>
    </div>
</form>
